Mark Recapture Experiments

  1. Write a function that takes as input P, m, and S. Your function should randomly draw S elements from the population with size P. Your function should count the number of marked elements in the sample and use that to return the estimate $\hat{P}$
  1. For $P=500$, $m=80$, and $S=90$, estimate $\hat{P}$ many times. Create a histogram summarizing the many results. What is the average $\hat{P}$ that your function produces? Does $\hat{P}$ tend to over- or under-estimate $P$?

$\hat{P}$ tends to overestimate.

  1. Repeat exercise 2 for other values of $P$, $m$, and $S$. Summarize your findings.

This is where I got a "Division by zero" error. I did what Elizabeth said and made r = 1 if r == 0. These estimates are very far below true value, though. Let's see if it's m or S that makes the difference.

With a large enough S, the algorithm again begins to overestimate, even with m being a relatively small number.

Interestingly, with a high m and a low S, the algorithm also overestimates.

Let's see what happens when P, m, and S are all equal.

This is interesting as well. The algorithm significantly overestimates the population in this case, more so than usual for a population of this size. This just further serves to underscore the fact that the equation itself is skewed and changing the inputs will not fix the problem.

Even with very small populations, this overestimates significantly.

To conclude, this function tends to overestimate the true population and also skews to the right significantly. This is not a good way to determine the true size of a population.